[Fix] freestyle-mock honors $PORT, drop server.listen string-patch#1432
[Fix] freestyle-mock honors $PORT, drop server.listen string-patch#1432BilalG1 wants to merge 5 commits into
Conversation
The multi-worker freestyle-mock rewrite (#1430) hardcoded `server.listen(8080)`, which collides with qstash inside the emulator container (supervisord sets `PORT=8180` for freestyle-mock). The local- emulator Dockerfile previously patched this via a string-replace, but the new source no longer matches the literal pattern, so qstash failed with `address already in use: 127.0.0.1:8080` and the backend never came up. Make the source respect `process.env.PORT` directly and remove the brittle replace.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdd a step to the qemu-emulator-build workflow’s ChangesCI KVM enablement
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis fix makes the freestyle-mock server honour
Confidence Score: 4/5Safe to merge — directly fixes the port collision that caused the emulator smoke test to fail. The core fix is correct and targeted: the source now reads The Important Files Changed
Sequence DiagramsequenceDiagram
participant S as supervisord
participant FM as freestyle-mock (server.mjs)
participant QS as qstash
Note over S: Reads PORT=8180 from supervisord.conf
S->>FM: "spawn with PORT=8180"
FM->>FM: "const PORT = process.env.PORT || 8080 → 8180"
FM->>FM: server.listen(8180)
Note over FM: Binds :8180 ✓
S->>QS: spawn (no PORT override)
QS->>QS: server.listen(8080)
Note over QS: Binds :8080 ✓ (no collision)
|
42a2a56 to
456a93c
Compare
Under cross-arch arm64 TCG in the qemu-emulator-build CI job, the deleteMany + createMany batch for ~1500-2000 event rows has been observed to take 40-50s, exceeding the previously-set 30s Prisma interactive-transaction ceiling (run 25835455849 hit 44.7s). The transaction uses deterministic IDs and is idempotent, so a looser bound has no correctness downside; it only kicks in on the slow TCG path.
456a93c to
358df4e
Compare
Under cross-arch arm64 TCG in the qemu-emulator-build CI job, a query in runBulldozerPaymentsInit/paginatedIngress exceeds the 120s server-side statement_timeout, returning Postgres error 57014 (P2010 from Prisma). KVM/native production runs the same query in well under a second; the looser bound only kicks in on the slow emulated path.
The bulldozer payments-seed cascade is O(N^2) in jsonb work because each setRow propagates through ~65 derived tables and an LFold maintains a per-customer subscription map that grows without bound. Under cross-arch arm64 TCG, even handfuls of seed rows blow past any reasonable statement_timeout — a single OneTimePurchase insert was observed at 304s. This Postgres instance only runs at qcow2-build time; production has its own server with its own timeout policy. Setting statement_timeout=0 here removes the CI flake without touching product behavior.
The smoke-test job has been silently running QEMU under TCG because the runner's /dev/kvm exists but isn't writable by the default user. The CLI's accelerator selection is a single check: `[ -w /dev/kvm ]` → otherwise it falls back to TCG. The build job mirrors this udev rule already and its KVM-accelerated cold boot completes in ~46s. Without KVM, recent dev merges have grown the boot's startup work past the 600s EMULATOR_READY_TIMEOUT under TCG. With KVM, this drops back to under a minute.
Summary
The multi-worker freestyle-mock rewrite (#1430) hardcoded
server.listen(8080), which collides with qstash inside the local-emulator container. Supervisord setsPORT=8180for freestyle-mock specifically to avoid this clash, but the new source ignoresprocess.env.PORT.The local-emulator Dockerfile previously bridged this with a
server.replace('server.listen(8080)', ...)string-patch on the embedded source. The new code isserver.listen(8080, () => { ... })— the literal'server.listen(8080)'substring no longer matches, so the replace silently no-ops and freestyle-mock binds 8080. qstash then can't start (address already in use: 127.0.0.1:8080→ FATAL), the backend (which depends on qstash) never comes up, and the emulator smoke test times out.Observed in this run:
Changes
docker/dependencies/freestyle-mock/Dockerfile:server.listen(PORT)wherePORT = process.env.PORT || 8080, plus the startup log reflects the actual port.docker/local-emulator/Dockerfile: drop the now-redundant string-replace for the listen call. The two remaining replaces (fs/promisesimport + node_modules symlink) are unrelated and kept.Test plan
PORT=8180is honored by freestyle-mock and qstash binds 8080 cleanly.Summary by CodeRabbit